﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_CM_GetSellman]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_CM_GetSellman];
GO
CREATE PROCEDURE [dbo].[sproc_CM_GetSellman]
@begintime datetime,
@endtime datetime

AS

    SELECT UDS_Staff.staff_name,UDS_CM_ClientContact.MarketmanID as SellmanID,sum(Fee) as Fee FROM UDS_CM_ClientContact,UDS_Staff
    WHERE (contacttime between @begintime and @endtime) 
    AND UDS_CM_ClientContact.MarketmanID=UDS_Staff.Staff_ID
    group by UDS_Staff.staff_name,UDS_CM_ClientContact.MarketmanID